home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / Macintosh Tracker 1.1 Source / Original Tracker 3.10 Source / analyzer.c next >
Encoding:
C/C++ Source or Header  |  1993-05-22  |  2.3 KB  |  144 lines  |  [TEXT/KAHL]

  1. /* analyzer.c */
  2.  
  3. /* read module files and output statistics on them */
  4.  
  5. /* $Id: analyzer.c,v 3.1 1993/01/16 17:00:27 espie Exp espie $
  6.  * $Log: analyzer.c,v $
  7.  * Revision 3.1  1993/01/16  17:00:27  espie
  8.  * Added patch for non termio.
  9.  *
  10.  * Revision 3.0  1992/11/18  16:08:05  espie
  11.  * New release.
  12.  *
  13.  */
  14.  
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18.  
  19. #include "defs.h"
  20. #include "extern.h"
  21. #include "song.h"
  22. #include "pref.h"
  23.  
  24. LOCAL char *id = "$Id: analyzer.c,v 3.1 1993/01/16 17:00:27 espie Exp espie $";
  25.  
  26. int error;
  27.  
  28. /* dummy function for linking wo termio */
  29. BOOL run_in_fg()
  30.     {
  31.     return TRUE;
  32.     }
  33.  
  34. struct song *do_read_song(name, type)
  35. char *name;
  36. int type;
  37.     {
  38.     struct song *song;
  39.     FILE *file;
  40.  
  41.     file = open_file(name, "r", getenv("MODPATH"));
  42.     if (!file)
  43.         return NULL;
  44.     song = read_song(file, type); 
  45.     close_file(file);
  46.     if (song)
  47.         puts(name);
  48.     return song;
  49.     }
  50.  
  51.  
  52. BOOL use_command[16];
  53. BOOL use_extended[16];
  54.  
  55. void analyze_block(b)
  56. struct block *b;
  57.     {
  58.     int i, j;
  59.     struct event *e;
  60.  
  61.     for (i = 0; i < BLOCK_LENGTH; i++)
  62.         for (j = 0; j < NUMBER_TRACKS; j++)
  63.             {
  64.             e = &b->e[j][i];
  65.             switch(e->effect)
  66.                 {
  67. #if 0
  68.             case 13:    /* skip */
  69.                 return;
  70.             case 11:    /* fastskip */
  71.                 return;
  72. #endif
  73.             case 14:
  74.                 use_extended[HI(e->parameters)] = TRUE;
  75.                 break;
  76.             default:
  77.                 use_command[e->effect] = TRUE;
  78.                 }
  79.             }
  80.     }
  81.  
  82.  
  83. void analyze_song(song)
  84. struct song *song;
  85.     {
  86.     int i;
  87.  
  88.     for (i = 0; i < NUMBER_SAMPLES; i++)
  89.         {
  90.         if (song->samples[i].start)
  91.             {
  92.             if (song->samples[i].finetune)
  93.                 printf("Sample %d: finetune is %d\n", 
  94.                     i, song->samples[i].finetune);
  95.             }
  96.         }
  97.     for (i = 0; i < 16; i++)
  98.         {
  99.         use_command[i] = FALSE;
  100.         use_extended[i] = FALSE;
  101.         }
  102.     for (i = 0; i < song->info.maxpat; i++)
  103.         analyze_block(song->info.pblocks+i);
  104.     for (i = 0; i < 16; i++)
  105.         if (use_command[i])
  106.             printf("%3d", i);
  107.     for (i = 0; i < 16; i++)
  108.         if (use_extended[i])
  109.             printf("%3dE", i);
  110.     printf("\n");
  111.     }
  112.  
  113. int main(argc, argv)
  114. int argc;
  115. char **argv;
  116.     {
  117.     int i;
  118.  
  119.     struct pref pref;
  120.     struct song *song;
  121.     int default_type;
  122.  
  123.     default_type = BOTH;
  124.     pref.tolerate = 2;
  125.  
  126.     create_notes_table();
  127.  
  128.     for (i = 1; i < argc; i++)
  129.         {
  130.         song = do_read_song(argv[i], NEW);
  131.         if (!song && error != NEXT_SONG)
  132.             song = do_read_song(argv[i], OLD);
  133.         if (song)
  134.             {
  135.             analyze_song(song);
  136.             release_song(song);
  137.             }
  138.         }
  139.     }
  140.  
  141.         
  142.  
  143.  
  144.